package com.zbcz.erp.activity

import android.os.Bundle
import androidx.activity.viewModels
import com.zbcz.erp.R
import com.zbcz.erp.adapter.MyApplyToolsAdapter
import com.zbcz.erp.bean.MyToolsBean
import com.zbcz.erp.databinding.ActivityMyApplyBinding
import com.zbcz.erp.util.DensityUtils
import com.zbcz.erp.util.onSingleClick
import com.zbcz.erp.viewmodel.MyToolsViewModel

class MyApplyActivity : BaseActivity() {


    private lateinit var mBinding: ActivityMyApplyBinding

    private val mToolsViewModel: MyToolsViewModel by viewModels()

    companion object {

        val mCommonToolsList = mutableListOf(
            MyToolsBean(R.id.travel_reimbursement_form, "差旅费报销单"),
            MyToolsBean(R.id.business_trip_form, "出差申请表"),
            MyToolsBean(R.id.reimbursement_form, "报销单"),
            MyToolsBean(R.id.apply_for_seal, "用印申请"),
            MyToolsBean(R.id.private_car_public_trip_record, "私车公用行程记录表"),
            MyToolsBean(R.id.erp_work, "ERP工作流"),
//            MyToolsBean(R.id.travel_reimbursement_form, "差旅费报销单", R.drawable.plane_icon),
//            MyToolsBean(R.id.business_trip_form, "出差申请表", R.drawable.plane_icon),
//            MyToolsBean(R.id.reimbursement_form, "报销单", R.drawable.business_trio_icon),
//            MyToolsBean(R.id.apply_for_seal, "用印申请", R.drawable.green_user_icon),
        )
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        mBinding = ActivityMyApplyBinding.inflate(layoutInflater)
        setContentView(mBinding.root)
        init()
        super.onCreate(savedInstanceState)
    }

    private fun init() {
        mBinding.clParent.setPadding(
            0,
            DensityUtils.dp2px(this, 48f),
            0,
            0
        )
        mBinding.clTitle.ivCommonBack.onSingleClick {
            finish()
        }
        mBinding.clTitle.tvTitle.text = "我的申请"
//        val mToolsAdapter = MyApplyToolsAdapter()
//        mToolsAdapter.submitList(mToolsList)
//        mBinding.rcMyToolsList.adapter = mToolsAdapter
        val mCommonToolsAdapter = MyApplyToolsAdapter()
        mBinding.rcCommonUseList.adapter = mCommonToolsAdapter
        mToolsViewModel.getMyToolsBeanList()
        mToolsViewModel.myToolsBeanLiveData.observe(this) {
            mCommonToolsAdapter.submitList(it)
        }
    }
}